import { NestFactory } from '@nestjs/core'
import { SystemAppModule } from './systemApp.module'
import { TransformInterceptor } from '@app/comm/interceptors/transform.interceptor'
import { AllExceptionsFilter } from '@app/comm/exceptions/base.exception.filter'
import { HttpExceptionFilter } from '@app/comm/exceptions/http.exception.filter'
import { generateDocument } from './doc'

// declare const module: any

async function bootstrap() {
  const app = await NestFactory.create(SystemAppModule)

  // 添加全局响应数据格式化拦截器
  app.useGlobalInterceptors(new TransformInterceptor())

  // 添加全局异常处理
  app.useGlobalFilters(new AllExceptionsFilter(), new HttpExceptionFilter())

  // 添加swagger 接口文档
  generateDocument(app)
  // swagger绑定token中间件

  await app.listen(4000)
}
bootstrap()
